home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_04
/
allison
/
convert3.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-06
|
413b
|
36 lines
LISTING 3 - Illustrates an implicit user-defined conversion
// convert3.cpp
#include <iostream.h>
struct A
{
double x;
A(double d)
{
cout << "A::A(double)" << endl;
x = d;
}
};
void f(const A& a)
{
cout << "f: " << a.x << endl;
}
main()
{
A a(1);
f(a);
f(2);
return 0;
}
// Output:
A::A(double)
f: 1
A::A(double)
f: 2